/**
 * 第 5 讲 - 双向数据绑定
 */

import React from 'react'

export default class BidrectDataBind extends React.Component {
  constructor() {
    super()

    this.state = {
      value: ''
    }
  }

  render() {
    return (
      <div>
        <h2>双向数据绑定</h2>
        <p>value={this.state.value}</p>

        <button onClick={() => {
          this.setState({ value: 'srxboys' })
        }}>改变value值</button>

        <hr />

        <input value={this.state.value} onChange={(event) => {
          const target = event.target || ''
          const value = target.value || ''
          console.log('value=', value)
          this.setState({  value })
        }} />
        
      </div>
    )
  }
}